/*******************************************************************************
 * Copyright (c) 2012, 2013 XML-Print Project.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     XML-Print Project - initial API and implementation
 ******************************************************************************/
package info.xmlprint.font;

import java.util.HashSet;
import java.util.Set;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

public class FontInfo {

	private String fontPath, fontName, fontFamilyName, fontVariable, fontType, fontSource,
			selected = "true";

	private boolean hasSmallCap = false;

	private Set<String> fontFeatures = new HashSet<String>();

	public String getSelected() {
		return selected;
	}

	public void setSmallCap(boolean b) {
		hasSmallCap = b;
	}

	public String getFontFamilyName() {
		return fontFamilyName;
	}

	public void setFontFamilyName(String fontFamilyName) {
		this.fontFamilyName = fontFamilyName;
	}

	public boolean hasSmallCap() {
		return hasSmallCap;
	}

	public void addFeature(String featureName) {
		fontFeatures.add(featureName);
	}

	public void removeFeature(String featureName) {
		fontFeatures.remove(featureName);
	}

	public boolean hasFeature(String featureName) {
		return fontFeatures.contains(featureName);
	}

	public void setSelected(String selected) {
		this.selected = selected;
	}

	public String getFontSource() {
		return fontSource;
	}

	public void setFontSource(String fontSource) {
		this.fontSource = fontSource;
	}

	public String getFontPath() {
		return fontPath;
	}

	public void setFontPath(String fontPath) {
		this.fontPath = fontPath;
	}

	public String getFontType() {
		return fontType;
	}

	public void setFontType(String fontType) {
		this.fontType = fontType;
	}

	public String getFontName() {
		return fontName;
	}

	public void setFontName(String fontName) {
		this.fontName = fontName;
	}

	public String getFontVariable() {
		return fontVariable;
	}

	public void setFontVariable(String fontVariable) {
		this.fontVariable = fontVariable;
	}
	
	public Document getXmlDocument() {
		Document doc = DocumentHelper.createDocument();
		Element font = doc.addElement("font"); 
		
		Element name=font.addElement("name");
		name.setText(getFontFamilyName());
		name.addAttribute("style", getFontVariable());
		
		Element location=font.addElement("location");
		location.setText(getFontPath());
		return doc;
	}

}
